#!/usr/bin/python

from hips.scheduling import constraint
from hips.scheduling import doctor
from hips.scheduling import problem
from hips.scheduling import schedule


def main(*args):
  d1 = doctor.Doctor(
      "McCoy",
      days_off=[5, 6],
      min_shifts=12,
      max_shifts=15,
      max_night_shifts=5,
      max_consecutive_days=5)
  d2 = doctor.Doctor(
      "Crusher",
      days_off=[7, 8],
      min_shifts=12,
      max_shifts=15,
      max_night_shifts=5,
      max_consecutive_days=5)
  d3 = doctor.Doctor(
      "Selar",
      days_off=[1, 2],
      min_shifts=10,
      max_shifts=10,
      max_night_shifts=3,
      max_consecutive_days=5)
  d4 = doctor.Doctor(
      "Bashir",
      days_off=[3, 4, 10, 11],
      min_shifts=12,
      max_shifts=15,
      max_night_shifts=5,
      max_consecutive_days=5)
  d5 = doctor.Doctor(
      "Zimmerman",
      days_off=[1, 2, 3, 4, 5, 6, 20, 25],
      min_shifts=12,
      max_shifts=15,
      max_night_shifts=5,
      max_consecutive_days=5)
  d6 = doctor.Doctor(
      "Chapel",
      days_off=[20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
      min_shifts=12,
      max_shifts=15,
      max_night_shifts=5,
      max_consecutive_days=5)
  d7 = doctor.Doctor(
      "Quaice",
      days_off=[11, 12, 13, 14, 15],
      min_shifts=12,
      max_shifts=15,
      max_night_shifts=5,
      max_consecutive_days=4)

  s = problem.SchedulingProblem(schedule.Schedule(30))
  s.AddDoctor(d1)
  s.AddDoctor(d2)
  s.AddDoctor(d3)
  s.AddDoctor(d4)
  s.AddDoctor(d5)
  s.AddDoctor(d6)
  s.AddDoctor(d7)

  i = s.Solve()
  for solution in i:
    print
    print "Final solution:"
    if solution:
      print solution
      print s.FormatSolution(solution)
      print
      print "SUCCESS"
    else:
      print "No solutions found"
    break
  print
  print "Iterations: %d" % s.iterations
  print
  print constraint.GetConstraintRejectionReasons()

if __name__ == "__main__":
  main()
